package com.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Result extends BaseEntity{

    @Transient
    final Integer r_true=0;
    @Transient
    final Integer r_less=1;
    @Transient
    final Integer r_more=2;
    @Transient
    final Integer r_wrong=3;
    @Transient
    final Integer r_null=4;

    @Temporal(TemporalType.TIMESTAMP)
    private Date commitTime;

    @ManyToOne
    private User student;

    @ManyToOne
    private Question question;

    @ManyToMany
    private List<Option> options;

    @JsonBackReference
    public User getStudent() {
        return student;
    }

    public void setStudent(User student) {
        this.student = student;
    }

    @JsonBackReference
    public Question getQuestion() {
        return question;
    }

    public void setQuestion(Question question) {
        this.question = question;
    }

    @JsonIgnore
    public List<Option> getOptions() {
        return options;
    }

    public void setOptions(List<Option> options) {
        this.options = options;
    }
}
